load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")

cc_library(
    name = "boost.lockfree",
    hdrs = glob(["include/**/*.hpp"]),
    features = ["parse_headers"],
    includes = ["include"],
    visibility = ["//visibility:public"],
    deps = [
        "@boost.align",
        "@boost.assert",
        "@boost.atomic",
        "@boost.config",
        "@boost.core",
        "@boost.parameter",
        "@boost.predef",
        "@boost.static_assert",
        "@boost.type_traits",
    ],
)

cc_library(
    name = "boost.lockfree_test_lib",
    testonly = True,
    deps = [
        ":boost.lockfree",
        "@boost.interprocess",
        "@boost.test//:unit_test_main",
        "@boost.thread",
    ],
)

cc_test(
    name = "destructor_test",
    srcs = ["test/destructor_test.cpp"],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "freelist_test",
    srcs = [
        "test/freelist_test.cpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "queue_bounded_stress_test",
    srcs = [
        "test/queue_bounded_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [
        ":boost.lockfree_test_lib",
    ],
)

cc_test(
    name = "queue_fixedsize_stress_test",
    srcs = [
        "test/queue_fixedsize_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "queue_interprocess_test",
    srcs = ["test/queue_interprocess_test.cpp"],
    tags = ["manual"],  # doesn't work on Debian
    deps = [
        ":boost.lockfree",
        "@boost.interprocess",
        "@boost.thread",
    ],
)

cc_test(
    name = "queue_test",
    srcs = ["test/queue_test.cpp"],
    tags = ["manual"],  # doesn't work on Mac
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "queue_unbounded_stress_test",
    srcs = [
        "test/queue_unbounded_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "spsc_queue_stress_test",
    srcs = [
        "test/spsc_queue_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "spsc_queue_test",
    srcs = [
        "test/spsc_queue_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "stack_bounded_stress_test",
    srcs = [
        "test/stack_bounded_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "stack_fixedsize_stress_test",
    srcs = [
        "test/stack_fixedsize_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "stack_interprocess_test",
    srcs = ["test/stack_interprocess_test.cpp"],
    tags = ["manual"],  # doesn't work on Debian
    deps = [
        ":boost.lockfree",
        "@boost.interprocess",
    ],
)

cc_test(
    name = "stack_test",
    srcs = ["test/stack_test.cpp"],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "stack_unbounded_stress_test",
    srcs = [
        "test/stack_unbounded_stress_test.cpp",
        "test/test_common.hpp",
        "test/test_helpers.hpp",
    ],
    deps = [":boost.lockfree_test_lib"],
)

cc_test(
    name = "tagged_ptr_test",
    srcs = ["test/tagged_ptr_test.cpp"],
    deps = [":boost.lockfree_test_lib"],
)
